import {useReducer} from 'react'

const USERNAME = 'USERNAME'
const PASSWORD = 'PASSWORD'
const PASSWORDAGAIN = 'PASSWORDAGAIN'
const EMAIL = 'EMAIL'
const PHONE = 'PHONE'
const CODE = 'CODE'


const reducer = (state, action) => {
  switch (action.type){
    case USERNAME:
      return {...state, username: action.value}
    case PASSWORDAGAIN:
      return {...state, passwordAgain: action.value}
    case PASSWORD:
      return {...state, password: action.value}
    case EMAIL:
      return {...state, email: action.value}
    case PHONE:
      return {...state, phone: action.value}
    case CODE:
      return {...state, code: action.value}
    default:
      return state
  }
}
const initialState = {
  username: false,
  password: false,
  passwordAgain: false,
  email: false,
  phone: false,
  code: false,
}
function useRegisterTipState() {
  const [tipState, tipDispatch] = useReducer(reducer, initialState)

  return {tipState, tipDispatch}
}

export default useRegisterTipState